<?php
session_start();
?>
<!--
This is the UI for users when the want to choose an activity to be deleted.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <title>Rotaract DLSU</title>
        <meta http-equiv="Content-Type" content="text/html"/>
        <meta name="robots" content="index,follow"/>
        <meta name="distribution" content="global"/>
        <meta name="description" content=""/>
        <meta name="keywords" content=""/>
        <link href="css/style.css" rel="stylesheet" type="text/css" media="screen" />
        <link rel="stylesheet" href="css/jquery-ui-1.8.21.custom.css"/>
        <link rel="stylesheet" href="css/demos.css"/>
        <script src="js/jquery-1.7.2.min.js"></script>
        <script src="js/jquery.ui.core.js"></script>
        <script src="js/jquery.ui.widget.js"></script>
        <script src="js/jquery.ui.datepicker.js"></script>

        <script>
            $(function() {
                $( "#datepicker" ).datepicker({
                    changeMonth: true,
                    changeYear: true,
                    dateFormat: 'yy-mm-dd'
                });
            });
        </script>

    </head>
    <body>
        <div id="container2">
            <div id="main3">
                <table width="100%" cellspacing="0" cellpadding="0">
                    <tr>
                        <td class="main_nav">
                            <div id="main_text2"> 
                                <center>
                                    <h2>Delete an Activity</h2>
                                    <?
                                    include 'getActivityList.php';
                                    ?>
                                    <form name="fordelete" action="RAC-deleteActivityUI.php" method="POST" >
                                        <table border ="1" cellpadding="10" class="myTable">
                                            <tr>
                                                <td><b>Select</b></td>
                                                <td><b>Name of Activity</b></td>
                                                <td><b>Date</b></td>
                                                <td><b>Description</b></td>
                                                <td><b>Image</b></td>
                                            </tr>
                                            <br/>
                                            <br/>
                                            <?
                                            while ($row = mysql_fetch_array($result)) {
                                                $id = $row['id'];
                                                $title = $row['title'];
                                                $date = $row['date'];
                                                $desc = $row['desc'];
                                                $img = $row['imageurl'];
                                                if ($img != '') {
                                                    echo ' <tr>';
                                                    echo "     <td><input type='radio' name='deleteName' value='$title'/></td>";
                                                    echo '     <td>' . $title . '</td>';
                                                    echo '     <td>' . $date . '</td>';
                                                    echo '     <td>' . $desc . '</td>';
                                                    echo '     <td><img src=' . $img . ' height="50" width="50"></td>';
                                                    echo '</tr>';
                                                } else {
                                                    echo ' <tr>';
                                                    echo "     <td><input type='radio' name='deleteName' value='$title'/></td>";
                                                    echo '     <td>' . $title . '</td>';
                                                    echo '     <td>' . $date . '</td>';
                                                    echo '     <td>' . $desc . '</td>';
                                                    echo '     <td>No image available.</td>';
                                                    echo '</tr>';
                                                }
                                            }
                                            ?>
                                        </table>
                                        <input type="submit" name="submitDelete" value="Delete" onclick="confirm('Are you sure?')"/>
                                    </form>
                                <?php
                                $confirm = '';
                                if (isset($_POST['submitDelete'])){
                                include 'RAC-deleteActivity.php';
                                
                                if($confirm){
                                    echo "<h4>Delete Successful! Please refresh to see changes.</h4>";
                                }
                                }
                                ?>
                                    <br/>
                                    <br/>
                                </center>
                            </div>
                        </td>

                    </tr>
                </table>
            </div>
        </div>
    </body>
</html>

